package com.wksc.workflow.controller;

import com.wksc.workflow.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * Description:
 * Author: Zero
 * CreateTime: 2013-12-23 14:58
 */
@Controller
@RequestMapping(value = "/user")
public class UsersController {

    @Autowired
    private UsersService usersService;

    @RequestMapping(value = "login", method = RequestMethod.POST)
    public ModelAndView login(String userName, String pwd) {
        ModelAndView view = new ModelAndView("/index");
        if (usersService.login(userName, pwd)) {
            view.addObject("code", 0);
            view.addObject("msg", "登录成功");
        } else {
            view.addObject("code", 1);
            view.addObject("msg", "登录失败");
        }
        return view;
    }

}
